"""
广泛性焦虑量表（GAD-7）是一种常用的自评量表，用于评估广泛性焦虑障碍的严重程度。
GAD-7包含7个问题，每个问题的得分范围是0到3分，总分范围是0到21分。根据总分，可以将焦虑症状的严重程度分为几个等级。
"""
class GAD7:
    def __init__(self, answers):
        self.answers = answers
        self.total_score = 0

    def calculate_score(self):
        self.total_score = sum(int(self.answers[f'q{i}']) for i in range(1, 8))

    def get_severity(self):
        if self.total_score <= 4:
            return '无或极少焦虑症状'
        elif 5 <= self.total_score <= 9:
            return '轻度焦虑'
        elif 10 <= self.total_score <= 14:
            return '中度焦虑'
        else:
            return '重度焦虑'

    def get_scores(self):
        return self.total_score, self.get_severity()

# # 示例使用
# answers = {
#     'q1': '3',
#     'q2': '2',
#     'q3': '1',
#     'q4': '0',
#     'q5': '2',
#     'q6': '1',
#     'q7': '3'
# }
#
# gad7 = GAD7(answers)
# gad7.calculate_score()
# total_score, severity = gad7.get_scores()
# print("Total Score:", total_score)
# print("Severity:", severity)